package org.activequant.data.retrieval;

import org.activequant.container.services.ITimeStampService;
import org.activequant.core.domainmodel.data.MarketDataEntity;
import org.activequant.util.pattern.events.IEventSink;

/**
 * Interface of a generic market data replay service. Used for simulating live market via historic data.<br/>
 * An interface. IMarketDataReplayService extends Iterable&lt;MarketDataEntity&lt;?&gt;&gt;, IEventSink&lt;MarketDataEntity&lt;?&gt;&gt;, ITimeStampService. Defines the following methods:
 * <ul>
 * <li>IQuoteSubscriptionSource getQuoteSubscriptionSource();</li>
 * <li>ITradeIndicationSubscriptionSource getTradeIndicationSubscriptionSource();</li>
 * <li>ICandleSubscriptionSource getCandleSubscriptionSource();</li>
 * <li>IMarketDepthEventSubscriptionSource getMarketDepthEventSubscriptionSource();</li>
 * <li>int getStreamsSize();</li>
 * </ul>
 * Inherits the following methods:
 * <ul>
 * <li>Iterator&lt;T&gt; iterator();</li>
 * <li>void fire(T e);</li>
 * <li>TimeStamp currentTimeStamp();</li>
 * </ul>
 * <p>
 * External controller is in charge of pulling market data events via Iterable part of the interface
 * and pushing them into the IEventSink part of the interface. The usage example is as follows:
 * <pre>
 * IMarketDataReplayService replayService = ... // get or create a service
 * 
 * // use subscription interfaces as one would normally do
 * IQuoteSubscriptionSource quoteSource = replayService.getQuoteSubscriptionSource();
 * // subscribe, etc.
 * // do that same for trade/candle subscription sources
 * 
 * // pull historic data and push it to the subscribers 
 * for(MarketDataEntity entity : replayService) {
 *     replayService.fire(entity);
 * }
 * </pre>
 * <p>
 * <b>History:</b><br>
 *  - [13.01.2008] Created (Mike Kroutikov)<br>
 *
 *  @author Mike Kroutikov
 */
public interface IMarketDataReplayService extends Iterable<MarketDataEntity<?>>, IEventSink<MarketDataEntity<?>>, ITimeStampService {
	
	/**
	 * Quote subscription source. Subscription requests will be translated into
	 * historic requests, and latter will be aligned according to the timestamp with
	 * other streams, and accessible via Iterable part of the interface.
	 * 
	 * @return quote subscription source.
	 */
	IQuoteSubscriptionSource getQuoteSubscriptionSource();
	
	/**
	 * Trade indication subscription source. Subscription requests will be translated into
	 * historic requests, and latter will be aligned according to the timestamp with
	 * other streams, and accessible via Iterable part of the interface.
	 * 
	 * @return trade indication subscription source.
	 */
	ITradeIndicationSubscriptionSource getTradeIndicationSubscriptionSource();
	
	/**
	 * Candle subscription source. Subscription requests will be translated into
	 * historic requests, and latter will be aligned according to the timestamp with
	 * other streams, and accessible via Iterable part of the interface.
	 * 
	 * @return candle subscription source.
	 */
	ICandleSubscriptionSource getCandleSubscriptionSource();
	
	/**
	 * MarketDepthEvent subscription source. Subscription requests will be translated into
	 * historic requests, and latter will be aligned according to the timestamp with
	 * other streams, and accessible via Iterable part of the interface.
	 * 
	 * @return marketdepth Event subscription source.
	 */
	IMarketDepthEventSubscriptionSource getMarketDepthEventSubscriptionSource();
	
	/**
	 * TickerNews subscription source. Subscription requests will be translated into
	 * historic requests, and latter will be aligned according to the timestamp with
	 * other streams, and accessible via Iterable part of the interface.
	 * 
	 * @return ticker news subscription source.
	 */
	ITickerNewsSubscriptionSource getTickerNewsSubscriptionSource();
	
	int getStreamsSize();
}